 use "$data\women_analysis.dta", clear
 
 tab ITTanalysis, gen(treatment)
 rename treatment1 control
 rename treatment2 treated
 lab var control "dummy for control women"
 lab var treated "dummy for treated women"
 bysort HHID: gen HHIDrepeat=_N
 lab var HHIDrepeat "no. of learners in a HH"
 sort HHIDrepeat
 unique HHID if HHIDrepeat>1
 replace treated=2 if treated==0
 sort HHID treated
 bysort HHID: replace treated=treated[1]
 replace treated=0 if treated==2
 replace control=2 if control==0
 sort HHID control
 bysort HHID: replace control=control[1]
 replace control=0 if control==2
 egen treatcontrolsameHH=rowtotal(treated control)
 lab var treatcontrolsameHH "HHs with and w/o mixed treatment status women"
 lab define treatcontrol 1 "HHs w/o mixed status" 2 "HHs with mixed status"
 lab values treatcontrolsameHH treatcontrol
 replace treatcontrolsameHH=0 if treatcontrolsameHH==1
 replace treatcontrolsameHH=1 if treatcontrolsameHH==2
 lab define samehh 0 "HHs w/o mixed status" 1 "HHs with mixed status"
 lab values treatcontrolsameHH samehh
 replace anyhelp=0 if pid_helpedinhome=="T"
 gen tutor=0 if anyhelp!=.
 replace tutor=1 if pid_helpedinhome=="T"

 global childedu admission_school Dabsentschool dropoffatschool askingforhomework Dtimespenthomework womanhelphomework tutor
 global childhealth Ddays_sick medicalhelp placeofmedicalhelp presence_woman_treatment
 
 balancetable (mean) (mean if treatcontrolsameHH==1) (mean if treatcontrolsameHH==0) (diff treatcontrolsameHH) $childedu $childhealth if ITTanalysis==0 & childageyears<=16 using "$results\TableB7.xls", ///
            ctit("Full sample" "Mixed status HHs" "Control only HHs" "Difference") leftctitle("Child level outcomes") ///
			vce(cluster learnerid) varlabels fe(strata) nonumbers replace

 exit
			
	
			
